<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="org.jeecgframework.web.system.pojo.base.CbsServiceLogEntity" %>
<%@include file="/context/mytags.jsp" %>

<html>
<head>
    <title>远程服务完工报告</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css"/>
    <script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.min.js"></script>
    <%--<script src="/plug-in/jquery/jquery-1.8.0.min.js" type="text/javascript"></script>--%>
</head>
<body>
<div style="margin-bottom:10px;">
    <c:if test="${editReport || cbsService.speedStatus ne '7'}">
        <div style="text-align: center; width: 100%; ">
            <c:if test="${!editReport}">
                <a href="#" id="btn1" class="easyui-linkbutton l-btn" onclick="zan()">暂存</a>
            </c:if>
            <a href="#" id="btn" class="easyui-linkbutton l-btn" onclick="sub()">提交</a>
        </div>
    </c:if>
    <input type="hidden" id="sessionId" value="${pageContext.session.id}">
</div>
<form id="myform" name="myform" action="" method="post">
    <div class="subtitle">
        <p>完工报告</p>
        <input type="hidden" name="editReport" value="${editReport}">
        <input type="hidden" id="type" name="type" value="${type}">
        <input type="hidden" id="cbserviceId" name="serviceId.id" value="${cbsService.id}">
        <input type="hidden" id="cbserviceCode" value="${cbsService.code}">
        <input type="hidden" id="reportCategory" name="reportCategory" value="2">
        <input type="hidden" id="reportId" name="reportId" value="${cbsServiceReportEntity.id}"/>
        <input id="id" name="id" type="hidden" value="${cbsServiceReportEntity.id }">
        <input id="createName" name="createName" type="hidden" value="${cbsServiceReportEntity.createName }">
        <input id="createBy" name="createBy" type="hidden" value="${cbsServiceReportEntity.createBy }">
        <input id="createDate" name="createDate" type="hidden" value="${cbsServiceReportEntity.createDate }">
        <input id="updateName" name="updateName" type="hidden" value="${cbsServiceReportEntity.updateName }">
        <input id="updateBy" name="updateBy" type="hidden" value="${cbsServiceReportEntity.updateBy }">
        <%--<input id="updateDate" name="updateDate" type="hidden" value="${cbsServiceReportEntity.updateDate }">--%>
        <input type="hidden" id="typeRole" value="${typeRole}"/>
        <div class="line"></div>
        <table class="nobordertable noborder">
            <tbody>
            <tr>
                <td class="al_r" width="20%">
                    <label>完工单附件:</label>
                </td>
                <td width="30%">
<c:if test="${editReport || cbsService.status ne '4'}">
                    <input type="button" value="上传附件" id="uploadFile01"/><span id="file1"></span>
</c:if>
                    <input type="hidden" id="finishFile" value="${cbsServiceReportEntity.finishFile.id}">
                    <c:forEach items="${zyFileLogEntityList}" var="zyFileLogEntityList">
                     <span id="${zyFileLogEntityList.id}">
                    <a class="color-blue" href="fileUploadController.do?downLoadFile&fileLogId=${zyFileLogEntityList.id}">${zyFileLogEntityList.oldFileName}</a>
                    <c:if test="${type ne 'look'}">
                        <a onclick="delFileForShow('${zyFileLogEntityList.id}')">删除</a>
                    </c:if>
                        </span>
                    </c:forEach>
                </td>
                <td class="al_r" width="20%">
                    <label>维修延期证明:</label>
                </td>
                <td width="30%">
<c:if test="${editReport || cbsService.status ne '4'}">
                    <input type="button" value="上传附件" id="uploadFile06"/>
</c:if>
    <input type="hidden" id="delayFile"><span id="file6"></span>
                    <c:forEach items="${zyFileLogEntityList6}" var="zyFileLogEntityList">
                    <span id="${zyFileLogEntityList.id}">
                    <a class="color-blue" href="fileUploadController.do?downLoadFile&fileLogId=${zyFileLogEntityList.id}">${zyFileLogEntityList.oldFileName}</a>
                    < <c:if test="${type ne 'look'}">
                        <a onclick="delFileForShow('${zyFileLogEntityList.id}')">删除</a>
                    </c:if>
                        </span>
                    </c:forEach>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">
                    <label>维修前诊断包:</label>
                </td>
                <td width="30%">
<c:if test="${editReport || cbsService.status ne '4'}">
                    <input type="button" value="上传诊断包" id="uploadFile02"/>
</c:if>
                    <span id="file2">
                      <span id="${cbsServiceReportEntity.repairFrontFile.id}">
                   <a class="color-blue" href="fileUploadController.do?downLoadFile&fileLogId=${cbsServiceReportEntity.repairFrontFile.id}">${cbsServiceReportEntity.repairFrontFile.oldFileName}</a>
                    <c:if test="${cbsServiceReportEntity.repairFrontFile.id !=null}">

                        <c:if test="${type ne 'look'}">
                            <a onclick="delFileForShowBefore('${cbsServiceReportEntity.repairFrontFile.id}')">删除</a>
                        </c:if>
                    </c:if>
                      </span>
                </span>
                    <input type="hidden" id="repairFrontFile" name="repairFrontFile.id"
                           value="${cbsServiceReportEntity.repairFrontFile.id}">


                </td>
                <td class="al_r" width="20%">
                    <label>整改函:</label>
                </td>
                <td width="30%">
<c:if test="${editReport || cbsService.status ne '4'}">
                    <input type="button" value="上传附件" id="uploadFile03"/>
</c:if>
                    <span id="file3">
                    <c:forEach items="${zyFileLogEntityList3}" var="zyFileLogEntityList">
                    <span id="${zyFileLogEntityList.id}">
                   <a class="color-blue" href="fileUploadController.do?downLoadFile&fileLogId=${zyFileLogEntityList.id}">${zyFileLogEntityList.oldFileName}</a>

                        <c:if test="${type ne 'look'}">
                            <a onclick="delFileForShow('${zyFileLogEntityList.id}')">删除</a>
                        </c:if>
                    </span>
                    </c:forEach>
                </span>
                    <input type="hidden" id="rectificationFile" value="${cbsServiceReportEntity.rectificationFile.id}">
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">
                    <label>维修后诊断包:</label>
                </td>
                <td width="30%">
<c:if test="${editReport || cbsService.status ne '4'}">
                    <input type="button" value="上传诊断包" id="uploadFile04"/>
</c:if>
    <span id="file4">
                     <span id="${cbsServiceReportEntity.repairAfterFile.id}">

                    <a class="color-blue" href="fileUploadController.do?downLoadFile&fileLogId=${cbsServiceReportEntity.repairAfterFile.id}">${cbsServiceReportEntity.repairAfterFile.oldFileName}</a>
                         <c:if test="${cbsServiceReportEntity.repairAfterFile.id !=null}">

                             <c:if test="${type ne 'look'}">
                                 <a onclick="delFileForShowAfter('${cbsServiceReportEntity.repairAfterFile.id}')">删除</a>
                             </c:if>
                    </c:if>
                    </span>

                </span>
                    <input type="hidden" id="repairAfterFile" name="repairAfterFile.id"
                           value="${cbsServiceReportEntity.repairAfterFile.id}">
                </td>
                <td class="al_r" width="20%">
                    <label>克隆包:</label>
                </td>
                <td width="30%">
	                <c:if test="${editReport || cbsService.status ne '4'}">
		                <input type="button" value="上传克隆包" id="uploadFile07"/>
	                </c:if>
	                <span id="file7">
                        <c:forEach items="${zyFileLogEntityList7}" var="zyFileLogEntityList">
                            <span id="${zyFileLogEntityList.id}">
                                <a class="color-blue" href="fileUploadController.do?downLoadFile&fileLogId=${zyFileLogEntityList.id}">${zyFileLogEntityList.oldFileName}</a>
                                <c:if test="${type ne 'look'}">
	                                <a onclick="delFileForShow('${zyFileLogEntityList.id}')">删除</a>
                                </c:if>
                            </span>
                        </c:forEach>
                    </span>
	                <input type="hidden" id="cloneFile" <c:forEach items="${zyFileLogEntityList7}" var="zyFileLogEntityList">class="${zyFileLogEntityList.oldFileName}"</c:forEach> />
                </td>
            </tr>
            </tbody>
        </table>
        <div class="line"></div>
        <table class="nobordertable noborder">
            <tbody>
            <tr>
                <td class="al_r" width="20%">
                    <label>现场照片:</label>
                </td>
                <td colspan="3">
                    <select name="photoType" id="photoType">
                        <c:forEach items="${photos}" var="photo">
                            <option value="${photo.typecode}">${photo.typename}</option>
                        </c:forEach>

                    </select>
<c:if test="${editReport ||cbsService.status ne '4'}">
                    <input type="file" id="uploadFile05"/>
</c:if>
    <input type="hidden" id="photoFile"/>

                    <span class="color-org">提示：</span><span class="color-hui">请按完工要求上传照片</span>
                </td>
            </tr>
            <tr>
                <td></td>
                <td><div style="width: 800px;"  id="file5"></div>
                    <div style="width: 900px;">
                    <c:forEach items="${zyFileLogEntityList5}" var="zyFileLogEntityList">
                    <div style="width: 200px;display: inline-block">
                        <span id="${zyFileLogEntityList.id}">
                    <a class="color-blue" href="fileUploadController.do?downLoadFile&fileLogId=${zyFileLogEntityList.id}">${zyFileLogEntityList.oldFileName}</a>

                        <c:if test="${type ne 'look'}">
                            <a onclick="delFileForShow('${zyFileLogEntityList.id}')">删除</a>
                        </c:if>
                        </span>
                    </div>
                    </c:forEach>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="line"></div>
        <div style="text-align: center; font-weight: bold;font-size:17px;">现场信息记录</div>
        <div><span style="font-weight: bold;">放映机</span></div>
        <table class="nobordertable noborder">
            <tbody>
            <tr>
                <td class="al_r" width="20%">
                    <label><font style="color: red">*</font>放映机序列号:</label>
                </td>
                <td width="30%">
                    <input name="sn" value="${cbsServiceReportEntity.sn}"
                                                            readOnly="true" id="sn"/>
                </td>
                <td class="al_r" width="20%">
                    <label><font style="color: red">*</font>放映机型号:</label>
                </td>
                <td width="30%">
                    <select name="equipmentType" id="equipmentType">
                    <c:forEach items="${mapList}" var="mapList">
                        <option value="${mapList.id}"
                                <c:if test="${cbsServiceReportEntity.equipmentType==mapList.id}">selected="selected"</c:if>>${mapList.type_desc}</option>
                    </c:forEach>
                </select>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">
                    <label>放映机运行时间:</label>
                </td>
                <td width="30%">
                    <input name="equipmentRunTime" id="equipmentRunTime"
                           value="${cbsServiceReportEntity.equipmentRunTime}"/>
                </td>
                <td class="al_r" width="20%">
                    <label><font style="color: red">*</font>激光改造类型:</label>
                </td>
                <td width="30%">
                    <select name="jgReform" id="jgReform">
                        <c:forEach items="${jgs}" var="types">
                            <option value="${types.typecode}"
                                    <c:if test="${types.typecode == cbsServiceReportEntity.jgReform }">selected="selected"</c:if>>${types.typename}</option>
                        </c:forEach>
                    </select>
                </td>
            </tr>

            </tbody>
        </table>
        <div class="line"></div>
        <div><span style="font-weight: bold;">放映环境监测</span></div>
        <table class="nobordertable noborder">
            <tbody>
            <tr>
                <td class="al_r" width="20%">
                    <label>温度:</label>
                </td>
                <td width="30%">
                    <input name="wd" value="${cbsServiceReportEntity.wd}" id="wd" max="50" min="-20"
                           onblur="ifValue(1,this)"/>
                    <font style="color: red" hidden="hidden" id="maxValue">最大值是50，请重新输入</font>
                    <font style="color: red" hidden="hidden" id="minValue">最小值是-20，请重新输入</font>
                    <font style="color: red" hidden="hidden" id="reservedValue">请保留一位小数点</font>
                </td>
                <td class="al_r" width="20%">
                    <label>湿度:</label>
                </td>
                <td width="30%">
                    <input name="sd" id="sd" value="${cbsServiceReportEntity.sd}"/>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">
                    <label>电压:</label>
                </td>
                <td width="30%">
                    <input name="dy" value="${cbsServiceReportEntity.dy}" id="dy" max="500" min="0"
                           onblur="ifValue(2,this)"/>
                    <font style="color: red" hidden="hidden" id="maxValue2">最大值是500，请重新输入</font>
                    <font style="color: red" hidden="hidden" id="minValue2">最小值是0，请重新输入</font>
                    <font style="color: red" hidden="hidden" id="reservedValue2">请保留一位小数点</font>
                </td>
                <td class="al_r" width="20%">
                    <label>零地电压:</label>
                </td>
                <td width="30%">
                    <input name="lddy" value="${cbsServiceReportEntity.lddy}" id="lddy" max="30" min="0"
                           onblur="ifValue(3,this)"/>
                    <font style="color: red" hidden="hidden" id="maxValue3">最大值是30，请重新输入</font>
                    <font style="color: red" hidden="hidden" id="minValue3">最小值是0，请重新输入</font>
                    <font style="color: red" hidden="hidden" id="reservedValue3">请保留一位小数点</font>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="line"></div>
        <div><span style="font-weight: bold;">光源监测</span></div>
        <table class="nobordertable noborder">
            <tbody>
            <tr>
                <td class="al_r" width="20%">
                    <label>光源品牌:</label>
                </td>
                <td width="30%">
                    <select name="gypp" id="gypp">
                    <c:forEach items="${types2}" var="ty">
                        <option value="${ty.typecode}"
                                <c:if test="${ty.typecode == cbsServiceReportEntity.gypp }">selected="selected"</c:if>>${ty.typename}</option>
                    </c:forEach>
                </select>
                </td>
                <td class="al_r" width="20%">
                    <label>光源型号:</label>
                </td>
                <td width="30%">
                    <input name="gyxh" value="${cbsServiceReportEntity.gyxh}" id="gyxh"/>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">
                    <label>光源运行时间:</label>
                </td>
                <td width="30%">
                    <input name="gyRunTime" id="gyRunTime"
                                                            value="${cbsServiceReportEntity.gyRunTime}"/>
                </td>
                <td class="al_r" width="20%">
                    <label>点灯次数:</label>
                </td>
                <td width="30%">
                    <input name="ddcs" value="${cbsServiceReportEntity.ddcs}"
                                                            id="ddcs"/>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="line"></div>
        <div><span style="font-weight: bold;">服务器&3D监测</span></div>
        <table class="nobordertable noborder">
            <tbody>
            <tr>
                <td class="al_r" width="20%">
                    <label>服务器品牌:</label>
                </td>
                <td width="30%">
                    <select name="serverType">
                        <c:forEach items="${types}" var="types">
                            <option value="${types.typecode}"
                                    <c:if test="${typse.typecode == cbsServiceReportEntity.serverType }">selected="selected"</c:if>>${types.typename}</option>
                        </c:forEach>
                    </select>
                </td>
                <td class="al_r" width="20%">

                </td>
                <td width="30%">

                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">
                    <label>服务器序列号:</label>
                </td>
                <td width="30%">
                    <input name="serverSn" value="${cbsServiceReportEntity.serverSn}"/>
                </td>
                <td class="al_r" width="20%">
                    <label>服务器软件版本:</label>
                </td>
                <td width="30%">
                    <input name="serverSoftVer" value="${cbsServiceReportEntity.serverSoftVer}"/>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%">
                    <label>3D设备型号（巴可）:</label>
                </td>
                <td width="30%">
                    <input name="server3dType" value="${cbsServiceReportEntity.server3dType}"/>
                </td>
                <td class="al_r" width="20%">
                    <label>3D设备序号（巴可）:</label>
                </td>
                <td width="30%">
                    <input name="server3dSn" value="${cbsServiceReportEntity.server3dSn}"/>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="line"></div>
        <div style="margin-bottom:10px;"><span style="font-weight: bold;">软件版本信息</span></div>
        <table class="ftable">
            <tbody>
            <tr>
                <th>软件版本信息</th>
                <th>维修前</th>
                <th>维修后</th>
            </tr>
            <tr>
                <td>放映机软件版本</td>
                <td><input name="repairFront1" id="repairFront1" value="${cbsServiceReportEntity.repairFront1}"/></td>
                <td><input name="repairAfter1" id="repairAfter1" value="${cbsServiceReportEntity.repairAfter1}"/></td>
            </tr>
            <tr>
                <td>ICP/TI/ICMP软件版本</td>
                <td><input name="repairFront2" id="repairFront2" value="${cbsServiceReportEntity.repairFront2}"/></td>
                <td><input name="repairAfter2" id="repairAfter2" value="${cbsServiceReportEntity.repairAfter2}"/></td>
            </tr>
            <tr>
                <td>Enigma软件版本</td>
                <td><input name="repairFront3" id="repairFront3" value="${cbsServiceReportEntity.repairFront3}"/></td>
                <td><input name="repairAfter3" id="repairAfter3" value="${cbsServiceReportEntity.repairAfter3}"/></td>
            </tr>
            <tr>
                <td>触摸屏软件版本</td>
                <td><input name="repairFront4" id="repairFront4" value="${cbsServiceReportEntity.repairFront4}"/></td>
                <td><input name="repairAfter4" id="repairAfter4" value="${cbsServiceReportEntity.repairAfter4}"/></td>
            </tr>
            </tbody>
        </table>
        <div class="line"></div>
        <div style="margin-bottom:10px;"><span style="font-weight: bold;">服务记录</span></div>
        <table class="nobordertable noborder">
            <tbody>
            <tr>
                <td class="al_r" width="20%" valign="top">
                    <label>故障现象:</label>
                </td>
                <td colspan="3">
                    <textarea style="width: 100%; height: 60px;" name="gzxx"
                              id="gzxx">${cbsServiceReportEntity.gzxx}</textarea>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%" valign="top">
                    <label>处理结果:</label>
                </td>
                <td colspan="3">
                    <textarea style="width: 100%; height: 60px;" name="cljg"
                              id="cljg">${cbsServiceReportEntity.cljg}</textarea>
                </td>
            </tr>
            <tr>
                <td class="al_r" width="20%" valign="top">
                    <label>备注:</label>
                </td>
                <td colspan="3">
                    <textarea style="width: 100%; height: 60px;" id="memo"
                              name="memo">${cbsServiceReportEntity.memo}</textarea>
                </td>
            </tr>
            </tbody>
        </table>
        <div style="margin-bottom:10px;"><span style="font-weight: bold;">附加任务</span></div>
        <input name="attr" type="hidden" id="attr">
        <table class="ftable">
            <tr>
                <th>选择</th>
                <th>对象</th>
                <th>待办内容</th>
                <th>已分派次数</th>
                <th>已完成次数</th>
                <th>未完成次数</th>
            </tr>
            <c:forEach items="${cbsAttachTaskEntities}" var="attr">
                <tr>
                    <td><input type="checkbox" value="${attr.id}" name="ids"/></td>
                    <td>${attr.objectName}</td>
                    <td>${attr.content}</td>
                    <td>${attr.assignmentTotal}</td>
                    <td>${attr.completeTotal}</td>
                    <td>${attr.notCompleteTotal}</td>
                </tr>

            </c:forEach>
        </table>
        <div class="line"></div>
        <div style="margin-bottom:10px;"><span style="font-weight: bold;">关键备件替换情况</span>&nbsp;&nbsp;<a
                class="easyui-linkbutton l-btn" onclick="addEquipment()">添加备件</a></div>
        <table class="ftable" id="addEquipment">
            <tbody>
            <tr>
                <th>新备件类型</th>
                <th>新备件序列号</th>
                <th>新备件二维码</th>
                <th>新备件号</th>
                <th>旧备件序列号</th>
                <th>旧备件二维码</th>
                <th>操作</th>
            </tr>
            <c:if test="${cbsSceneEquipmentUseEntityList!=null}">
                <c:forEach items="${cbsSceneEquipmentUseEntityList}" var="cbsSceneEquipmentUse">
                    <tr id="${cbsSceneEquipmentUse.id}">
                        <td>
                            <select style="width: 80%;" name="newEquipmentType" class="type"
                                    id="${cbsSceneEquipmentUse.id}0" onchange="getItem('${cbsSceneEquipmentUse.id}')">
                                <c:forEach items="${maps}" var="map">
                                    <option value="${map.id}"
                                            <c:if test="${map.id == cbsSceneEquipmentUse.typeId.id}">selected="selected"</c:if>>${map.type_desc}</option>
                                </c:forEach>

                            </select>
                        </td>
                        <td>
                            <input style="width: 80%;" name="newEquipmentSn" value="${cbsSceneEquipmentUse.sn}"/>
                        </td>
                        <td>
                            <input style="width: 80%;" name="newEquipmentCode"
                                   value="${cbsSceneEquipmentUse.equipmentErcode}"/>
                        </td>
                        <td>
                            <select style="width: 80%;" class="item" id="${cbsSceneEquipmentUse.id}1"
                                    name="newEquipment" onclick="getItem('${cbsSceneEquipmentUse.id}')">
                                <option value="${cbsSceneEquipmentUse.itemId.id}">${cbsSceneEquipmentUse.itemId.item}</option>
                            </select>
                        </td>
                        <td>
                            <input style="width: 80%;" name="oldEquipmentSn" value="${cbsSceneEquipmentUse.oldSn}"/>
                        </td>
                        <td>
                            <input style="width: 80%;" name="oldEquipmentCode"
                                   value="${cbsSceneEquipmentUse.oldErcode}"/>
                        </td>
                        <td>
                            <span class="color-blue" onclick="proEdit('${cbsSceneEquipmentUse.id}')">[删除]</span>
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
            </tbody>
        </table>
    </div>
</form>
</body>
<script>
    $("#btn").css("pointer-events", "auto");
    $("#btn1").css("pointer-events", "auto");
    $(function () {
        var cbsServiceId = $("#cbserviceId").val();
        $("#uploadFile06").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            queueID: 'instructionfile',
            /*fileTypeDesc : '文件格式:',
            fileTypeExts : '*.*',*/
            fileTypeDesc: '支持格式:*',
            fileTypeExts: '*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            fileSizeLimit: '50MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: '<%=basePath%>/cbsServiceController.do?fileUploadView&cbsServiceId=' + cbsServiceId + '&sessionId=' + $("#sessionId").val() + '&businessType=XC5',
            onUploadStart: function () {
                lockmask(true, '请稍等,导入中...');
            }, onUploadSuccess: function (file, data) {
                lockmask(false);
                var json = $.parseJSON(data).attributes;
                var name = json.name;
                var ins = name.lastIndexOf(".");
                var ins2 = name.length;
                var ho = name.substring(ins, ins2);
                var photoType = "维修延期证明";
                var photoName = photoType + ho;
                var fileIds = $("#fileId").val();
                $("#delayFile").val(json.id);
                var html = '<span id="li_file_' + json.id + '"><span class="color-blue" id="' + json.id + '">' + photoName + '</span>&nbsp;&nbsp; ' +
                    '<span style="cursor: pointer;" onclick=\'delFile6("' + json.id + '")\'>[删除]</span></span>';

                $("#file6").prepend(html);
                $.ajax({
                    type: "post",
                    data: {"id": json.id, "name": photoName},
                    dataType: "json",
                    url: "cbsServiceReportController.do?changeName",
                    success: function (data) {
                        var b = data.success;
                    }
                });
                // tip("上传成功！");
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
                ;
            }
        });
    });

    function delFileForShow(id) {
        var flag = true;
        $.ajax({
            url: "cbsServiceReportController.do?delFile",
            data: {
                "id": id
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#" + id + "").remove();
                    // $("#delayFile").val("");
                }
            }
        });
    }
    function delFileForShowAfter(id) {
        var flag = true;
        var cbsServiceId = $("#cbserviceId").val();
        $.ajax({
            url: "cbsServiceReportController.do?delFileAndId",
            data: {
                "id": id,
                "serviceId":cbsServiceId,
                "type":"2",
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#" + id + "").remove();
                    $("#repairAfterFile").val("");
                }
            }
        });
    }
    function delFileForShowBefore(id) {
        var flag = true;
        var cbsServiceId = $("#cbserviceId").val();
        $.ajax({
            url: "cbsServiceReportController.do?delFileAndId",
            data: {
                "id": id,
                "serviceId":cbsServiceId,
                "type":"1",
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#" + id + "").remove();
                    $("#repairFrontFile").val("");
                }
            }
        });
    }
    function delFile6(id) {
        var flag = true;
        $.ajax({
            url: "cbsServiceReportController.do?delFile",
            data: {
                "id": id
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#li_file_" + id + "").remove();
                    $("#delayFile").val("");
                }
            }
        });
    }

    function addEquipment() {
        $.ajax({
            url: "cbsServiceReportController.do?getUuid",
            cache: false,
            dataType: "json",
            type: "POST",
            error: function () {
            },
            success: function (uuid) {
                var html = "";
                html += "<tr id='" + uuid + "'><td><select style='width: 80%;' name='newEquipmentType' id='" + uuid + "0'  class='type' onchange=\"getItem('" + uuid + "')\"></select></td>";
                html += '<td><input style="width: 80%;" name="newEquipmentSn"/></td>';
                html += '<td><input style="width: 80%;" name="newEquipmentCode"/></td>';
                html += '<td><select style="width: 80%;" class="item" id="' + uuid + '1" name="newEquipment"><option value="0">--请选择--</option></select></td>';
                html += '<td><input style="width: 80%;" name="oldEquipmentSn"/></td>';
                html += '<td><input style="width: 80%;" name="oldEquipmentCode"/></td>';
                html += "<td><span class=\"color-blue\" onclick=\"proEdit('" + uuid + "')\">[删除]</span></td>";
                html += "</tr>";
                $("#addEquipment").append(html);
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "cbsServiceReportController.do?getType",
                    success: function (data) {
                        var obj = data.obj;
                        var ht = "<option value='0'>--请选择--</option>";
                        for (i in obj) {
                            ht += "<option value='" + obj[i].id + "'>" + obj[i].type_desc + "</option>";
                        }
                        $("#" + uuid + "0").html(ht);
                    }
                });

            }
        });
    }

    function getItem(uuid) {
        var typeCode = $("#" + uuid + "0").val();
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "cbsServiceReportController.do?getItem&id=" + typeCode,
            success: function (data) {
                var obj = data.obj;
                var ht = "";
                if (obj != null) {
                    for (i in obj) {
                        ht += "<option value='" + obj[i].id + "'>" + obj[i].item + "</option>";
                    }
                } else {
                    ht += "<option value='0'>请选择</option>";
                }
                $("#" + uuid + "1").html(ht);
            }
        });
    }

    function proEdit(uuid) {
        $("#" + uuid).remove();
    }

    $(function () {
        var cbsServiceId = $("#cbserviceId").val();
        $("#uploadFile01").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            queueID: 'instructionfile',
            /*fileTypeDesc : '文件格式:',
            fileTypeExts : '*.*',*/
            fileTypeDesc: '支持格式:*',
            fileTypeExts: '*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            fileSizeLimit: '50MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: '<%=basePath%>/cbsServiceController.do?fileUploadView&cbsServiceId=' + cbsServiceId + '&sessionId=' + $("#sessionId").val() + '&businessType=XC1',
            onUploadStart: function () {
                lockmask(true, '请稍等,导入中...');
            },
            onUploadSuccess: function (file, data) {
                lockmask(false);
                var json = $.parseJSON(data).attributes;
                var name = json.name;
                var ins = name.lastIndexOf(".");
                var ins2 = name.length;
                var ho = name.substring(ins, ins2);
                var photoType = "完工单附件";
                var photoName = photoType + ho;
                var fileIds = $("#fileId").val();
                $("#finishFile").val(json.id);
                var html = '<span id="li_file_' + json.id + '"><span class="color-blue" id="' + json.id + '">' + photoName + '</span>&nbsp;&nbsp; ' +
                    '<span style="cursor: pointer;" onclick=\'delFile("' + json.id + '")\'>[删除]</span></span>';

                $("#file1").prepend(html);
                $.ajax({
                    type: "post",
                    data: {"id": json.id, "name": photoName},
                    dataType: "json",
                    url: "cbsServiceReportController.do?changeName",
                    success: function (data) {
                        var b = data.success;
                    }
                });
                // tip("上传成功！");
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
                ;
            }
        });
    });
    $(function () {
        var cbsServiceId = $("#cbserviceId").val();
        $("#uploadFile02").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            queueID: 'instructionfile',
            /*fileTypeDesc : '文件格式:',
            fileTypeExts : '*.*',*/
            fileTypeDesc: '支持格式:*',
            fileTypeExts: '*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            fileSizeLimit: '50MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: '<%=basePath%>/cbsServiceReportController.do?fileUploadView&type=before&cbsServiceId=' + cbsServiceId + '&sessionId=' + $("#sessionId").val() + '&businessType=XC2',
            onUploadStart: function () {
                lockmask(true, '请稍等,导入中...');
            },
            onUploadSuccess: function (file, data) {
                lockmask(false);
                var json = $.parseJSON(data).attributes;
                if (json.ststus == 1) {
                    tip("诊断包与服务单序列号不一致，请重新上传");
                    return false;
                }
                var fileIds = $("#fileId").val();
                $("#repairFrontFile").val(json.id);
                var html = '<span id="li_file_' + json.id + '"><span class="color-blue" id="' + json.id + '">' + json.name + '</span>&nbsp;&nbsp; ' +
                    '<span style="cursor: pointer;" onclick=\'delFile2("' + json.id + '")\'>[删除]</span></span>';
                $("#file2").html(html);
                if (json.type == "before") {
                    $("#repairFront1").val(json.barcoVs);

                    if (typeof(json.tiVs) != "undefined") {

                        $("#repairFront2").val(json.tiVs);
                    }
                    if (typeof(json.ICMPvs) != "undefined") {

                        $("#repairFront2").val(json.ICMPvs);
                    }
                    $("#repairFront3").val("");
                    $("#repairFront4").val("");
                }

                // $.session.set("fileid",json.id);
                // $("#fileName").val(json.name);
                // console.log(json.id+"--"+json.name)
                // var html = '<span id="li_file_'+json.id+'"><span class="color-blue" id="'+json.id+'">'+json.name+'</span>&nbsp;&nbsp; ' +
                //     '<span style="cursor: pointer;" onclick=\'delFile("'+json.id+'")\'>[删除]</span></span>'
                // $("#fileName1").prepend(html);
                // tip("上传成功！");
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
                ;
            }
        });
    });

    function delFile2(id) {
        var flag = true;
        var cbsServiceId = $("#cbserviceId").val();
        $.ajax({
            url: "cbsServiceReportController.do?delFileAndId",
            data: {
                "id": id,
                "serviceId":cbsServiceId,
                "type":"1",
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#li_file_" + id + "").remove();
                    $("#repairFrontFile").val("");
                }
            }
        });
    }

    $(function () {
        var cbsServiceId = $("#cbserviceId").val();
        $("#uploadFile03").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            queueID: 'instructionfile',
            /*fileTypeDesc : '文件格式:',
            fileTypeExts : '*.*',*/
            fileTypeDesc: '支持格式:*',
            fileTypeExts: '*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            fileSizeLimit: '50MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: '<%=basePath%>/cbsServiceController.do?fileUploadView&cbsServiceId=' + cbsServiceId + '&sessionId=' + $("#sessionId").val() + '&businessType=XC3',
            onUploadStart: function () {
                lockmask(true, '请稍等,导入中...');
            },
            onUploadSuccess: function (file, data) {
                lockmask(false);
                var json = $.parseJSON(data).attributes;
                var name = json.name;
                var ins = name.lastIndexOf(".");
                var ins2 = name.length;
                var ho = name.substring(ins, ins2);
                var photoType = "整改函";
                var photoName = photoType + ho;
                var fileIds = $("#fileId").val();
                $("#rectificationFile").val(json.id);
                var html = '<span id="li_file_' + json.id + '"><span class="color-blue" id="' + json.id + '">' + photoName + '</span>&nbsp;&nbsp; ' +
                    '<span style="cursor: pointer;" onclick=\'delFile3("' + json.id + '")\'>[删除]</span></span>';

                $("#file3").prepend(html);
                $.ajax({
                    type: "post",
                    data: {"id": json.id, "name": photoName},
                    dataType: "json",
                    url: "cbsServiceReportController.do?changeName",
                    success: function (data) {
                        var b = data.success;
                    }
                });
                // tip("上传成功！");
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
                ;
            }
        });
    });

    function delFile3(id) {
        var flag = true;
        $.ajax({
            url: "cbsServiceReportController.do?delFile",
            data: {
                "id": id
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#li_file_" + id + "").remove();
                    $("#rectificationFile").val("");
                }
            }
        });
    }

    $(function () {
        var cbsServiceId = $("#cbserviceId").val();
        $("#uploadFile04").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            queueID: 'instructionfile',
            /*fileTypeDesc : '文件格式:',
            fileTypeExts : '*.*',*/
            fileTypeDesc: '支持格式:',
            fileTypeExts: '*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            fileSizeLimit: '50MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: '<%=basePath%>/cbsServiceReportController.do?fileUploadView&type=after&cbsServiceId=' + cbsServiceId + '&sessionId=' + $("#sessionId").val() + '&businessType=XC4',
            onUploadStart: function () {
                lockmask(true, '请稍等,导入中...');
            },
            onUploadSuccess: function (file, data) {
                lockmask(false);
                var json = $.parseJSON(data).attributes;
                var fileIds = $("#fileId").val();
                $("#repairAfterFile").val(json.id);
                var html = '<span id="li_file_' + json.id + '"><span class="color-blue" id="' + json.id + '">' + json.name + '</span>&nbsp;&nbsp; ' +
                    '<span style="cursor: pointer;" onclick=\'delFile4("' + json.id + '")\'>[删除]</span></span>';

                $("#file4").html(html);
                if (json.type == "after") {
                    $("#repairAfter1").val(json.barcoVs);
                    if (typeof(json.tiVs) != "undefined") {

                        $("#repairAfter2").val(json.tiVs);
                    }
                    if (typeof(json.ICMPvs) != "undefined") {

                        $("#repairAfter2").val(json.ICMPvs);
                    }
                    $("#gyRunTime").val(json.lampTime);
                    $("#equipmentRunTime").val(json.projectorTime);
                    $("#repairAfter3").val("");
                    $("#repairAfter4").val("");
                }
                // tip("上传成功！");
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
                ;
            }
        });
    });

    function delFile4(id) {
        var flag = true;
        var cbsServiceId = $("#cbserviceId").val();
        $.ajax({
            url: "cbsServiceReportController.do?delFileAndId",
            data: {
                "id": id,
                "serviceId":cbsServiceId,
                "type":"2",
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#li_file_" + id + "").remove();
                    $("#repairAfterFile").val("");
                }
            }
        });
    }

    $(function () {
        var cbsServiceId = $("#cbserviceId").val();
        // var photoType = $('select[name="photoType"] option:selected').text();
        // photoType = decodeURI(photoType);
        $("#uploadFile05").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: true,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            queueID: 'instructionfile',
            /*fileTypeDesc : '文件格式:',
            fileTypeExts : '*.*',*/
            fileTypeDesc: '支持格式:*',
            fileTypeExts: '*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            fileSizeLimit: '50MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: '<%=basePath%>/cbsServiceController.do?fileUploadView&cbsServiceId=' + cbsServiceId + '&sessionId=' + $("#sessionId").val() + '&photoType=' + photoType + '&businessType=XC5',
            onUploadStart: function () {
                lockmask(true, '请稍等,导入中...');
            },
            onUploadSuccess: function (file, data) {
                lockmask(false);
                var index = 0;
                var json = $.parseJSON(data).attributes;
                var name = json.name;
                var ins = name.lastIndexOf(".");
                var ins2 = name.length;
                var ho = name.substring(ins, ins2);
                var photoType = $('select[name="photoType"] option:selected').text();
                var photoName = photoType + ho;
                var fileIds = $("#fileId").val();
                $("#photoFile").val(json.id);
                var html = '<div style="width: 200px;display: inline-block"><span id="li_file_' + json.id + '"><span class="color-blue" id="' + json.id + '">' + photoName + '</span>&nbsp;&nbsp; ' +
                    '<span style="cursor: pointer;" onclick=\'delFile5("' + json.id + '")\'>[删除]</span></span></div>';
                if(index>4){
                    $("#file5").prepend(html+"<br>");
                }else {
                    $("#file5").prepend(html);
                }
                $.ajax({
                    type: "post",
                    data: {"id": json.id, "name": photoName},
                    dataType: "json",
                    url: "cbsServiceReportController.do?changeName",
                    success: function (data) {
                        var b = data.success;
                    }
                });
                // tip("上传成功！");
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
                ;
            }
        });
    });

    function delFile5(id) {
        var flag = true;
        $.ajax({
            url: "cbsServiceReportController.do?delFile",
            data: {
                "id": id
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#li_file_" + id + "").remove();
                    //$("#repairAfterFile").val("");
                }
            }
        });
    }

    function delFile(id) {
        var flag = true;
        $.ajax({
            url: "cbsServiceReportController.do?delFile",
            data: {
                "id": id
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                    tip(data.msg);
                } else {
                    tip(data.msg);
                    //隐藏标签
                    $("#li_file_" + id + "").remove();
                    $("#finishFile").val("");
                }
            }
        });
    }

    $(function () {
        var cbsServiceId = $("#cbserviceId").val();
        $("#uploadFile07").uploadify({
            buttonText: '上传文件',
            auto: true,
            progressData: 'speed',
            multi: false,
            height: 20,
            width: 60,
            overrideEvents: ['onDialogClose'],
            queueID: 'instructionfile',
            fileTypeDesc: '支持格式:',
            fileTypeExts: '*.*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            fileSizeLimit: '50MB',
            swf: 'plug-in/uploadify/uploadify.swf',
            uploader: '<%=basePath%>/cbsServiceController.do?fileUploadView&cbsServiceId=' + cbsServiceId + '&sessionId=' + $("#sessionId").val() + '&businessType=XC7',
            onUploadStart: function () {
                lockmask(true, '请稍等,导入中...');
            }, onUploadSuccess: function (file, data) {
                lockmask(false);
                var json = $.parseJSON(data).attributes;

                $("#cloneFile").val(json.id);
                $("#cloneFile").attr("class",json.name);
                console.log($("#cloneFile").attr("class"));
                var html = '<div style="width: 200px;display: inline-block"><span id="li_file_' + json.id + '"><span class="color-blue" id="' + json.id + '">' + json.name + '</span>&nbsp;&nbsp; ' +
                    '<span style="cursor: pointer;" onclick=\'delFile7("' + json.id + '")\'>[删除]</span></span></div>';

                $("#file7").html(html);
            }, onFallback: function () {
                tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
            }, onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                        break;
                    case -120:
                        tip("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        tip("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });
    });

    function delFile7(id) {
        var flag = true;
        $.ajax({
            url: "cbsServiceReportController.do?delFile",
            data: {
                "id": id
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (!data.success) {
                    flag = false;
                } else {
                    //隐藏标签
                    $("#li_file_" + id + "").remove();
                    $("#cloneFile").val("");
                    $("#cloneFile").removeAttr("class");
                }
                tip(data.msg);
            }
        });
    }

    function ifValue(type, item) {
        var value = item.value;
        var max = item.max;
        var min = item.min;
        if (type == 1) {
            if (parseInt(value) > parseInt(max)) {
                $("#maxValue").show();
                $("#minValue").hide();
                $("#reservedValue").hide();
            } else if (parseInt(value) < parseInt(min)) {
                $("#maxValue").hide();
                $("#minValue").show();
                $("#reservedValue").hide();
            } else if (!/^[0-9]+([.][0-9]{1}){0,1}$/.test(value)) {
                $("#maxValue").hide();
                $("#minValue").hide();
                $("#reservedValue").show();
            } else {
                $("#maxValue").hide();
                $("#minValue").hide();
                $("#reservedValue").hide();
            }
        }
        if (type == 2) {

            if (parseInt(value) > parseInt(max)) {
                $("#maxValue2").show();
                $("#minValue2").hide();
                $("#reservedValue2").hide();
            } else if (parseInt(value) < parseInt(min)) {
                $("#maxValue2").hide();
                $("#minValue2").show();
                $("#reservedValue2").hide();
            } else if (!/^[0-9]+([.][0-9]{1}){0,1}$/.test(value)) {
                $("#maxValue2").hide();
                $("#minValue2").hide();
                $("#reservedValue2").show();
            } else {
                $("#maxValue2").hide();
                $("#minValue2").hide();
                $("#reservedValue2").hide();
            }
        }
        if (type == 3) {

            if (parseInt(value) > parseInt(max)) {
                $("#maxValue3").show();
                $("#minValue3").hide();
                $("#reservedValue3").hide();
            } else if (parseInt(value) < parseInt(min)) {
                $("#maxValue3").hide();
                $("#minValue3").show();
                $("#reservedValue3").hide();
            } else if (!/^[0-9]+([.][0-9]{1}){0,1}$/.test(value)) {
                $("#maxValue3").hide();
                $("#minValue3").hide();
                $("#reservedValue3").show();
            } else {
                $("#maxValue3").hide();
                $("#minValue3").hide();
                $("#reservedValue3").hide();
            }
        }
    }

    function sub() {
        $("#btn").css("pointer-events", "none");
        var sn = $("#sn").val();
        var equipmentType = $("#equipmentType").val();
        var equipmentRunTime = $("#equipmentRunTime").val();
        var jgReform = $("#jgReform").val();
        var gypp = $("#gypp").val();
        var gyxh = $("#gyxh").val();
        var gyRunTime = $("#gyRunTime").val();
        var ddcs = $("#ddcs").val();
        var gcq = $("#gcq").val();
        var gzxx = $("#gzxx").val();
        var cljg = $("#cljg").val();
        var memo = $("#memo").val();
        var repairFront2 = $("#repairFront2").val();
        var repairFront1 = $("#repairFront1").val();
        var repairAfter2 = $("#repairAfter2").val();
        var repairAfter1 = $("#repairAfter1").val();
        if (sn == '' && sn.length == 0) {
            tip("请填写放映机序列号");
            $("#btn").css("pointer-events", "auto");
            return false;
        }
        if (equipmentType == '' && equipmentType.length == 0) {
            tip("请填写放映机型号");
            $("#btn").css("pointer-events", "auto");

            return false;
        }
//         if (equipmentRunTime == '' && equipmentRunTime.length == 0) {
//             tip("放映机运行时间不能为空");
//             $("#btn").css("pointer-events", "auto");
//             return false;
//         }
        if (jgReform == '' && jgReform.length == 0) {
            tip("请选择激光改造类型");
            $("#btn").css("pointer-events", "auto");

            return false;
        }

        var cloneFile = $("#cloneFile").attr("class");   //克隆包name
        if(cloneFile != undefined && cloneFile.indexOf("clone") == -1){
            tip("克隆包文件名称不规范，请改为包含\"clone\"的文件名!");
            return false;
        }

//         if (gypp == '' && gypp.length == 0) {
//             tip("请选择光源品牌");
//             $("#btn").css("pointer-events", "auto");

//             return false;
//         }

//         if (ddcs == '' && ddcs.length == 0) {
//             tip("请填写点灯次数");
//             $("#btn").css("pointer-events", "auto");

//             return false;
//         }
//         if (repairFront1 == '' && repairFront1.length == 0) {
//             tip("软件版本信息不能为空");
//             $("#btn").css("pointer-events", "auto");
//             return false;
//         }
//         if (repairAfter1 == '' && repairAfter1.length == 0) {
//             tip("软件版本信息不能为空");
//             $("#btn").css("pointer-events", "auto");
//             return false;
//         }
//         if (repairFront2 == '' && repairFront2.length == 0) {
//             tip("软件版本信息不能为空");
//             $("#btn").css("pointer-events", "auto");
//             return false;
//         }
//         if (repairAfter2 == '' && repairAfter2.length == 0) {
//             tip("软件版本信息不能为空");
//             $("#btn").css("pointer-events", "auto");
//             return false;
//         }
        // if (gzxx == '' && gzxx.length == 0) {
        //     tip("请填写故障现象");
        //     $("#btn").css("pointer-events", "auto");
        //
        //     return false;
        // }
        // if (cljg == '' && cljg.length == 0) {
        //     tip("请填写处理结果");
        //     $("#btn").css("pointer-events", "auto");
        //
        //     return false;
        // }
        // if (memo == '' && memo.length == 0) {
        //     tip("请填写备注");
        //     $("#btn").css("pointer-events", "auto");
        //
        //     return false;
        // }
        var ids = [];
        $("input:checked").each(function (i) {
            var id = $(this).val();
            ids.push(id);
        });
        var delIds = ids.toString();
        delIds = decodeURI(delIds);
        $("#attr").val(delIds);
        $.ajax({
            type: "post",
            url: "cbsServiceReportController.do?doAdd",
            data: $("#myform").serialize(),
            dataType: "json",
            success: function (data) {
                if(data.success){
                    tip(data.msg);
                    var cbserviceId = $("#cbserviceId").val();
                    $.ajax({
                        type: "post",
                        data: {"id": cbserviceId},
                        url: "cbsServiceReportController.do?getRole",
                        dataType: "json",
                        success: function (data) {
                            var tabName = $("#cbserviceCode").val();
                            var rData = data.attributes;
                            if (rData != null) {
                                var role = rData.role;
                                jQuery.messager.confirm('提示:', '是否提交返件申请?', function (event) {
                                    if (event) {
                                        if (role == "EG" || role == "AEG" || role == "barcoCSE") {
                                            addOneTab("待返件任务", "cbsReturnEquipmentController.do?cbsReturnEquipmentGCS");
                                            setTimeout("closetab('远程服务完工报告')", 1000);
                                        }
                                        if (role == "HD") {
                                            addOneTab("返件管理", "cbsReturnEquipmentController.do?cbsReturnEquipmentCSA");
                                            setTimeout("closetab('远程服务完工报告')", 1000);
                                        }
                                    } else {
                                        var type = $("#typeRole").val();
                                        if (type == '') {
                                            tip("提交成功");
                                            addOneTab("我的任务", "cbsServiceAssignListController.do?engineerlists");
                                            setTimeout("closetab('远程服务完工报告')", 1000);
                                        } else {
                                            tip("提交成功");
                                            closetab("编辑服务单"+tabName);
                                            window.top.$("#maintabs").tabs({
                                                title: "编辑服务单" + tabName,
                                                onBeforeClose: function (title, index) {
                                                }
                                            });
                                            window.top.$("#maintabs").tabs('close', "编辑服务单" + tabName);
                                            addOneTab("服务单管理", "cbsServiceController.do?cbsService");
                                            setTimeout("closetab('远程服务完工报告')",1000);
                                        }
                                    }
                                });
                            } else {
                                var type = $("#typeRole").val();
                                if (type == '') {
                                    tip("提交成功");
                                    addOneTab("我的任务", "cbsServiceAssignListController.do?engineerlists");
                                    setTimeout("closetab('远程服务完工报告')", 1000);

                                } else {
                                    tip("提交成功");
                                    closetab("编辑服务单"+tabName);
                                    window.top.$("#maintabs").tabs({
                                        title: "编辑服务单" + tabName,
                                        onBeforeClose: function (title, index) {
                                        }
                                    });
                                    window.top.$("#maintabs").tabs('close', "编辑服务单" + tabName);
                                    addOneTab("服务单管理", "cbsServiceController.do?cbsService");
                                    setTimeout("closetab('远程服务完工报告')",1000);
                                }
                            }
                        }
                    });
                } else {
                    tip(data.msg);
                }
            }
        });
    }

    function zan() {
        $("#btn1").css("pointer-events", "none");
        $.ajax({
            type: "post",
            url: "cbsServiceReportController.do?zanAdd",
            data: $("#myform").serialize(),
            dataType: "json",
            success: function (data) {
                tip(data.msg);
                var type = $("#type").val();
                if (type == 2) {
                    addOneTab("服务单管理", "cbsServiceController.do?cbsService");
                    setTimeout("closetab('远程服务完工报告')", 1000);
                } else {
                    addOneTab("我的任务", "cbsServiceAssignListController.do?engineerlists");
                    setTimeout("closetab('远程服务完工报告')", 1000);
                }
            }
        });
    }

    $(function () {
        var id = $('#province').val();
        $.post('loginWxController.do?getTerritoryCity', {id: id}, function (data) {
            data = $.parseJSON(data);
            $('#city').find('option').remove();
            var str = "";
            for (var i = 0; i < data.length; i++) {
                str += '<option value="' + data[i].id + '">' + data[i].territoryName + '</option>';
            }
            $('#city').append(str);
            if (cityId != '') {
                $('#city').val(cityId);
            }
        });
    });

    //二级联动
    function loadCity() {
        var id = $('#province').val();
        $.post('loginWxController.do?getTerritoryCity', {id: id}, function (data) {
            data = $.parseJSON(data);
            $('#city').find('option').remove();
            var str = "";
            for (var i = 0; i < data.length; i++) {
                str += '<option value="' + data[i].id + '">' + data[i].territoryName + '</option>';
            }
            $('#city').append(str);
            // if (cityId != '') {  cityId
            //     $('#city').val(cityId);
            // }
        });
    }

</script>
</html>
